﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Numbers.Transactions
{
    public delegate bool ProposedPropertyChangeCallback(IObjectInTransaction obj, string propName);
    public interface IObjectInTransaction
    {
        /// <summary>
        /// Fire when you want to propose a new value and others should pick it up. This should
        /// then propagate around the transaction until everyone is done. Once done, the below
        /// callback is called with the results.
        /// </summary>
        event ProposedPropertyChangeCallback ProposedPropertyChange;

        /// <summary>
        /// Transaction has finished. Time to roll back to the old value (!transactionIsGood) or keep the
        /// new value. Raise the regular PropertyChanged event if the latter guy is true (which it always
        /// will be if this transaction is good - otherwise just the first object that started the
        /// transaction inscase it is hooked up to the UI and the UI needs to be reset).
        /// </summary>
        /// <param name="transactionIsGood"></param>
        /// <param name="newValue"></param>
        /// <param name="oldValue"></param>
        /// <param name="raisePropChanged"></param>
        void TransactionOver(bool transactionIsGood, double newValue, double oldValue, bool raisePropChanged);

        string Name { get; }
    }
}
